package com.mbmed.doctor.lab1.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.lab1.bo.Lac1Bo;
import com.mbmed.doctor.lab1.mapper.Lac1;

/**
 * @file  Lac1Service.java
 * @author jiangcangpeng
 * @version 0.1
 * @todo	Lac1服务操作接口
 * Copyright(C), 2013-2014
 *		 Shenzhen Coordinates Software Development Co., Ltd.
 * History
 *   	1. Date: 2014-11-06 02:14:23
 *      	Author: jiangcangpeng
 *      	Modification: this file was created
 *   	2. ...
 */
@Path("/lac1")
@Component
public class Lac1Service {
	
	private static Logger logger = Logger.getLogger(Lac1.class);
	
	@Autowired
	private Lac1Bo lac1Bo;
	
	@Context
	Request request;

	
	/**
	 * 查找所有数据库记录
     * @return type : List 返回查询操作所有符合条件的记录的VO对象集合，操作失败返回null
     */
	@GET
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public List<Lac1> getAll() throws Exception{
        List<Lac1> list = new ArrayList<Lac1>();
        return lac1Bo.getAll();        
    }
	
    /**
     * 查找符合条件的所有数据库记录
     * @param id 与数据库中主键对应的值
     * @return type :  返回查询操作所有符合条件的记录的VO对象，操作失败返回null
     * @throws Exception
     */
	@GET
	@Path("{id}")
	@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})
    public Lac1 getLac1(@PathParam("id") String id) throws Exception{
    	Lac1 lac1 = null;
    	return lac1Bo.get(id);        
    }
    /**
     * 向数据库中插入一条记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : 返回插入操作是否成功
     * @throws Exception
     */
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	public Lac1 saveLac1(
			@FormParam("lac01") java.lang.Integer lac01,
			@FormParam("lab01") java.lang.Integer lab01,
			@FormParam("bbx01") java.lang.Integer bbx01,
			@FormParam("bbx01a") java.lang.Integer bbx01a,
			@FormParam("laj01") java.lang.Integer laj01,
			@FormParam("bfo01") java.lang.Integer bfo01,
			@FormParam("bey01") java.lang.Integer bey01,
			@FormParam("lac08") java.lang.String lac08,
			@FormParam("lac09") java.lang.String lac09,
			@FormParam("lac10") java.lang.String lac10,
			@FormParam("lac11") java.lang.String lac11,
			@FormParam("lac12") java.lang.String lac12,
			@FormParam("lac13") java.lang.String lac13,
			@FormParam("lac14") java.lang.String lac14,
			@FormParam("lac15") java.lang.String lac15,
			@FormParam("lac16") java.lang.String lac16,
			@FormParam("lac17") java.lang.String lac17,
			@FormParam("lac18") java.lang.String lac18,
			@FormParam("lac19") java.lang.Byte lac19,
			@FormParam("bby25") java.math.BigDecimal bby25,
			@FormParam("lac21") java.math.BigDecimal lac21,
			@FormParam("bce03a") java.lang.String bce03a,
			@FormParam("lac23") java.util.Date lac23,
			@FormParam("bce03b") java.lang.String bce03b,
			@FormParam("lac25") java.util.Date lac25,
			@FormParam("lac26") java.lang.Byte lac26,
			@FormParam("lac27") java.lang.Byte lac27,
			@FormParam("rownr") java.lang.Integer rownr,
			@FormParam("lac29") java.lang.String lac29,
			@FormParam("lac30") java.lang.String lac30,
			@FormParam("vaf01") java.lang.Integer vaf01,
			@FormParam("bbx01b") java.lang.Integer bbx01b,
			@FormParam("lac33") java.lang.Integer lac33,
			@Context HttpServletResponse servletResponse
	) throws Exception {
		Lac1 lac1 = new Lac1();
		lac1.setLac01(lac01);
		lac1.setLab01(lab01);
		lac1.setBbx01(bbx01);
		lac1.setBbx01a(bbx01a);
		lac1.setLaj01(laj01);
		lac1.setBfo01(bfo01);
		lac1.setBey01(bey01);
		lac1.setLac08(lac08);
		lac1.setLac09(lac09);
		lac1.setLac10(lac10);
		lac1.setLac11(lac11);
		lac1.setLac12(lac12);
		lac1.setLac13(lac13);
		lac1.setLac14(lac14);
		lac1.setLac15(lac15);
		lac1.setLac16(lac16);
		lac1.setLac17(lac17);
		lac1.setLac18(lac18);
		lac1.setLac19(lac19);
		lac1.setBby25(bby25);
		lac1.setLac21(lac21);
		lac1.setBce03a(bce03a);
		lac1.setLac23(lac23);
		lac1.setBce03b(bce03b);
		lac1.setLac25(lac25);
		lac1.setLac26(lac26);
		lac1.setLac27(lac27);
		lac1.setRownr(rownr);
		lac1.setLac29(lac29);
		lac1.setLac30(lac30);
		lac1.setVaf01(vaf01);
		lac1.setBbx01b(bbx01b);
		lac1.setLac33(lac33);

		return lac1 = lac1Bo.save(lac1);

	}
	/**
     * 删除数据库中与传入的值对象对应的记录
     * @param vo 与数据库中记录对应的值对象
     * @return type : boolean 返回删除操作是否成功
     * @throws Exception
     */
	@DELETE
	@Path("{id}")
	public boolean removeLac1(@PathParam("id") String id) throws Exception{
		if(id == null) return false;
    	return lac1Bo.remove(id);

	}
	
}
